import 'dart:convert';

import './storage.dart';

class UserService{

  static getUserInfo() async{
    List userinfo;
    try {
      List userInfoData = json.decode(await Storage.getString('userInfo'));
      userinfo = userInfoData;
    } catch(e) {
      userinfo = [];
    }
    return userinfo;
  }

  static getUserLoginState() async{
    List userInfo = await UserService.getUserInfo();
    if(userInfo.isNotEmpty && userInfo[0]['username'] != '') {
      return true;
    } else {
      return false;
    }
  }

  static loginOut() async{
    await Storage.remove('userInfo');
  }

}